package BS.servlet;

import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.sql.SQLException;
import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.commons.dbutils.QueryRunner;
import org.apache.commons.dbutils.handlers.BeanListHandler;
import org.apache.commons.lang3.StringUtils;

import BS.dao.daofactory;
import BS.entity.guanliyuan;
import BS.entity.guanliyuan;
import BS.utils.pageinfo;
import BS.utils.pathutils;
import BS.utils.propertiesUtils;

@WebServlet("/guanliyuan")
public class gServlet extends HttpServlet {
	@Override
	protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {

		doPost(req, resp);
	}
	
	@Override
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		request.setCharacterEncoding("UTF-8");
		String method = request.getParameter("method");
		if("edit".equals(method)) {
			this.findById(request, response);
		}
		
		
}
	private void findById(HttpServletRequest request, HttpServletResponse response) {
		try {
			request.setCharacterEncoding("UTF-8");
		} catch (UnsupportedEncodingException e1) {
			// TODO Auto-generated catch block
			e1.printStackTrace();
		}
		String id = request.getParameter("id");
try {
		guanliyuan guanliyuan = daofactory.getInstance().getguanliyuanDao().findByid(Integer.parseInt(id));
		request.setAttribute("guanliyuan", guanliyuan);
		request.getRequestDispatcher("guanliyuan/update.jsp").forward(request, response);
		} catch (Exception e) {
			// TODO: handle exception
		}
	}
}

